<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<title>编辑用户信息</title>
<link rel="stylesheet" href="/css/bootstrap.min.css">
<script src="/js/jquery/jquery.min.js"></script>
<script src="/js/jquery.validation/1.14.0/jquery.validate.min.js"></script>
<script src="/js/jquery.validation/1.14.0/messages_zh.min.js"></script>
<style>
input.error {
	border: 1px solid #E6594E;
}
</style>
</head>
<body>
	<div class="container">
		<form id="editHouseForm">
			<div class="form-group">
				<label for="name">用户名：</label> <input type="text"
					class="form-control" id="name"  value="${data.name}">
			</div>
			<div class="form-group">
				<label for="password">密码：</label> <input type="text"
					class="form-control" id="password" 
					value="${data.password}">
			</div>
			<div class="form-group">
				<label for="username">真实姓名：</label> <input type="text"
					class="form-control" id="username" 
					value="${data.username}">
			</div>
			<div class="form-group">
				<label for="telephone">真实姓名：</label> <input type="text"
					class="form-control" id="telephone" 
					value="${data.telephone}">
			</div>
			<div class="form-group">
				<label for="isadmin">是否管理员</label> <select class="form-control"
					id="isadmin" value="${data.isadmin}" >
					<option value="是" <#if "${data.isadmin}"=="是">selected=selected</#if>>是</option>
					<option value="不是" <#if "${data.isadmin}"=="不是">selected=selected</#if>>不是</option>
				</select>
			</div>
			<div class="form-group">
				<button type="button" id="saveBtn" class="btn btn-success">提交</button>
				<button type="button" id="cancelBtn" class="btn btn-default">取消</button>
				<input type="hidden" id="hid" value="${data.id}">
			</div>
		</form>
	</div>
	<script>
		var editUsers = function() {
			$.ajax({
				type : "GET",
				dataType : "json",
				url : "/users/update.do",
				data : {
					"id" : $("#hid").val(),
					"username" : $("#username").val(),
					"name" : $("#name").val(),
					"password" : $("#password").val(),
					"telephone" : $("#telephone").val(),
					"isadmin" : $("#isadmin").val()
				},
				success : function(msg) {
					$('#cancelBtn').click();
				},
			});
		}
		$('#saveBtn').on('click', function() {
			editUsers();
		});
		$('#cancelBtn').on('click', function() {
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		});
		
	</script>
</body>
</html>